﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using YGame.Base;

namespace AppFrame
{
	public class AppFrameService : YGame.Base.IAppFrameService
	{


		#region IAppFrameService 成员

        public event LoadModelEventHandler LoadModel;

		#region OnLoadModel
		/// <summary>
		/// Triggers the LoadModel event.
		/// </summary>
		public virtual void OnLoadModel(string value)
		{
			if (LoadModel != null)
			{
				string[] keyValue = value.Split(',');
				Trace.Assert(keyValue.Length == 2);
				LoadModel(keyValue[0], keyValue[1]);
			}
		}
		#endregion


		public event EventHandler Shutdown;
		/// <summary>
		/// 系统关闭请求
		/// </summary>
		/// <param name="value"></param>
		public void OnShutdown(string value)
		{
			Trace.Write("start shutdown service ...");
			if (Shutdown != null)
			{
				Shutdown(this, EventArgs.Empty);
			}
			Trace.Write("shutdown service ok ...");
			System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs();
			Application.Exit(e);
		}


		#endregion
	}
}
